package com.gxgeek.eshopinventory;

import com.gxgeek.eshopinventory.listener.InitListener;
import com.gxgeek.eshopinventory.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class EshopInventoryApplication {

    @Autowired
    private UserMapper userMapper;

    public static void main(String[] args) {
        SpringApplication.run(EshopInventoryApplication.class, args);

    }

    @Bean
    public ServletListenerRegistrationBean servletListenerRegistrationBean() {

        ServletListenerRegistrationBean servletListenerRegistrationBean =
                new ServletListenerRegistrationBean();

        servletListenerRegistrationBean.setListener(new InitListener());
        return servletListenerRegistrationBean;
    }

    @RequestMapping("/hello")
    public Object hello() {

        return userMapper.selectById(1L);
    }

}
